# AI Chat Makefile - 跨平台开发命令

.PHONY: help install dev build test clean

# 默认目标
help:
	@echo "AI Chat 开发命令:"
	@echo "  make install  - 安装所有依赖"
	@echo "  make dev      - 启动开发环境"
	@echo "  make build    - 构建生产版本"
	@echo "  make test     - 运行测试"
	@echo "  make clean    - 清理临时文件"

# 安装依赖
install:
	@echo "📦 安装Python依赖..."
	python -m venv .venv
	.venv\Scripts\activate && pip install -r requirements.txt
	@echo "📦 安装前端依赖..."
	cd frontend && npm install && cd ..

# 开发环境
dev:
	@echo "🚀 启动开发环境..."
	@if exist .venv (.venv\Scripts\activate && python scripts\start_server.py &) else (echo "❌ 请先运行 make install")
	@cd frontend && npm run dev

# 构建生产版本
build:
	@echo "🔨 构建生产版本..."
	cd frontend && npm run build

# 运行测试
test:
	@echo "🧪 运行测试..."
	.venv\Scripts\activate && python -m pytest

# 清理
clean:
	@echo "🧹 清理临时文件..."
	@if exist __pycache__ rmdir /s /q __pycache__
	@if exist backend\__pycache__ rmdir /s /q backend\__pycache__
	@if exist frontend\dist rmdir /s /q frontend\dist
	@if exist frontend\node_modules rmdir /s /q frontend\node_modules
